package itdep.domain.address;

import itdep.domain.NamedEntity;

import javax.persistence.*;
import java.util.HashSet;
import java.util.Set;

/**
 * @author Ivan Khalopik
 * @version $Revision: 47 $ $Date: 2010-07-05 09:28:44 +0000 (Mon, 05 Jul 2010) $
 */
@Entity
@Table(name = "CITY")
public class City extends NamedEntity {
	public static final String SETTLEMENT_PROPERTY = "settlement";
	public static final String DISTRICT_PROPERTY = "district";

	@Column(name = "CITY_CODE", nullable = true)
	private String cityCode;

	@ManyToOne(fetch = FetchType.LAZY)
	@JoinColumn(name = "ID_DISTRICT", nullable = false)
	private District district;

	@ManyToOne(fetch = FetchType.LAZY)
	@JoinColumn(name = "ID_SETTLEMENT", nullable = true)
	private Settlement settlement;

	@ManyToOne(fetch = FetchType.LAZY)
	@JoinColumn(name = "ID_CITY_TYPE", nullable = false)
	private CityType cityType;

	@OneToMany(mappedBy = "city")
	private Set<Street> streets = new HashSet<Street>();

	public District getDistrict() {
		return district;
	}

	public void setDistrict(District district) {
		this.district = district;
	}

	public Settlement getSettlement() {
		return settlement;
	}

	public void setSettlement(Settlement settlement) {
		this.settlement = settlement;
	}

	public CityType getCityType() {
		return cityType;
	}

	public void setCityType(CityType cityType) {
		this.cityType = cityType;
	}

	public String getCityCode() {
		return cityCode;
	}

	public void setCityCode(String cityCode) {
		this.cityCode = cityCode;
	}

	public Set<Street> getStreets() {
		return streets;
	}
}